package com.belizer.demo.timer;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

public class Demo {
    public static void main(String[] args) throws InterruptedException {
//        int i = 7;
//        System.out.println(i>>1);
        DemoTask demoTask = new DemoTask();

        Timer timer = new Timer("demoTask");
        timer.schedule(demoTask,5000);

        TimeUnit.SECONDS.sleep(5);

        timer.cancel();
//        TimeUnit.SECONDS.sleep(25);
    }

    private static class DemoTask extends TimerTask{
        @Override
        public void run() {
            System.out.println("hello java timer");
        }
    }
}
